fix: trim empty top-level else branches#498
Merged
ako merged 1 commit intomendixlabs:mainfrom May 2, 2026
Merged
Conversation
Symptom: describe could emit an empty top-level `else` when the false branch pointed at a continuation that had already been emitted while traversing the true branch. Re-executing the MDL removed that empty branch, leaving a roundtrip mismatch. Root cause: top-level IF traversal decided whether to emit `else` only by comparing `falseFlow.DestinationID` to the selected merge. That misses cases where the false destination is not the merge but traversal still emits no statements because the continuation is already visited. Fix: mirror nested IF traversal: emit the `else` line tentatively, traverse the false branch, and remove the line again if the traversal produced no statements. Tests: added a synthetic traversal regression test; `go test ./mdl/executor -run 'TopLevelIfRemovesEmptyElse|SequentialIfWithoutElse' -v`; `make build`; `make lint-go`; `make test`.
Collaborator
Review: fix: trim empty top-level else branchesVerdict: Approve What the PR doesFixes issue #497: when a false-branch destination was already visited via the true branch, The fix switches to a tentative-emit-then-retract pattern: append the No blockersCorrectness notes
Positive notes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #497.
Summary
elseif false-branch traversal emits no statementsValidation
go test ./mdl/executor -run 'TopLevelIfRemovesEmptyElse|SequentialIfWithoutElse' -vmake buildmake lint-gomake test